<template>
	<view class="router-view bcl-active">
		<uni-search-list :type="1"></uni-search-list>

		<!-- 登录提示 -->
		<view class="login-tips uni-footer box box-between box-column-center cl-white bcl-black-new" v-if="!userInfo">
			<view class="box-1">登录后为您提供更多惊喜~</view>
			<navigator url="/user/login">
				<view class="uni-button uni-button-radius login-btn">立即登录</view>
			</navigator>
		</view>

		<!-- 发布按钮 -->
		<div class="send-btn pointer" :class="{ top: !userInfo }" @click="toSendPage">
			<image src="/static/images/release_1.png" style="width: 50px; height: 50px;"></image>
		</div>
	</view>
</template>

<script>
	import {
		mapState
	} from "vuex";
	import uniSearchList from "@/components/searchList";

	export default {
		onShow() {
			uni.setStorageSync("lastPage", this.__route__ || this.route); // 记录最近一次访问的页面
		},
		onLoad() {
			
		},
		onTabItemTap(e) {
			// console.log(e);
			// var _this = this
			// uni.setTabBarItem({
			//   index: 0,
			//   text: '发布',
			//   pagePath:'/pages/index/release/submit?type=1',
			//   iconPath: 'static/icons/release.png',
			//   selectedIconPath: 'static/icons/index_active.png',
			//   success:function(res){
			// console.log("首页tab，监听",res);
			//       if(res.errMsg == 'setTabBarItem:ok'){
			//         if(e.text == '发布'){
			//         let url = _this.userInfo
			//           ? "/pages/index/release/submit?type=1"
			//           : "/user/login";

			//         uni.navigateTo({
			//           url,
			//         });
			//           // uni.navigateTo({
			//           //   url:'/pages/index/release/submit?type=1'
			//           // });
			//         }
			//           // alert(1)
			//           // if(e.pagePath == 'pages/index/index'){
			//           //      uni.switchTab({
			//           // url:'/pages/index/release/submit'
			//           //     });

			//           // }

			//       }
			//   }
			// })
		},
		// onTabItemTap(e){
		//   console.log(e)
		//   //  uni.$emit("searchListRefresh");

		//     let url = this.userInfo
		//       ? "/pages/index/release"
		//       : "/user/login";

		//     uni.navigateTo({
		//       url,
		//     });

		// },

		onPullDownRefresh() {
			uni.$emit("searchListRefresh");
		},


		onReachBottom() {
			uni.$emit("reachBottom");
		},

		methods: {
			toSendPage() {
				let url = this.userInfo ?
					"/pages/index/release/submit?type=1" :
					"/user/login";

				uni.navigateTo({
					url,
				});
			},
		},

		watch: {
			userInfo(n) {
			}
		},
		computed: {
			...mapState(["userInfo"]),
		},

		components: {
			uniSearchList,
		},
		data() {
			return {
				uesrid: ''
			}
		}
	};
</script>

<style lang="scss" scoped>
	// 登录提示
	.login-tips {
		height: 80upx;
		line-height: 1;
		padding: 20upx;

		navigator,
		uni-navigator {
			height: 60upx;
		}

		.login-btn {
			border: none;
			line-height: 1.5;
			background: linear-gradient(to bottom, $color-warning, $color-danger 80%);
		}
	}

	.send-btn {
		position: fixed;
		right: 15px;
		bottom: calc(var(--window-bottom) + 50px);
		border-radius: 50%;
		z-index: 10;

		&.top {
			bottom: calc(var(--window-bottom) + 100px);
		}
	}
</style>
